﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    xmlns:localVM="clr-namespace:estoque.ViewModel;assembly=estoque.ViewModel"
    xmlns:local="clr-namespace:estoque"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="estoque.MainWindow"
    Closing="OnWindowIsClosing"
    x:Name="Window" Title="estoque - ToDo-Manager" Height="600" Width="800" Background="#FF565656" FontFamily="Segoe Print">
    <Window.Resources>
        <local:PriorityBrushConverter x:Key="priorityBrushConverter" />
        <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
        <local:IsRunningToTextConverter x:Key="isRunningToTextConverter" />

        <DataTemplate DataType="{x:Type localVM:TaskVM}">
            <Grid Height="40">
                <Grid.ToolTip>
                    <TextBlock Text="{Binding ShortInfo}"/>
                </Grid.ToolTip>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="15"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Rectangle Margin="0,2,1,2" Grid.Column="0"  Fill="{Binding TaskPriority, Converter={StaticResource priorityBrushConverter}}" MouseLeftButtonUp="OnPriorityChange"/>
                <Rectangle Margin="0,2,5,2" Grid.Column="1" Grid.ColumnSpan="2" Fill="LightGray"/>
                <StackPanel Margin="0,2,5,2" Grid.Column="1" Orientation="Horizontal" Height="40" >
                    <Label Margin="2,0,0,0" VerticalContentAlignment="Center" Background="LightGray" Content="{Binding Title}" FontSize="16" VerticalAlignment="Bottom"/>
                </StackPanel>
                <StackPanel FlowDirection="RightToLeft" Margin="0,2,5,2" Grid.Column="2" Orientation="Horizontal">
                    <local:EllipseIcon MouseLeftButtonUp="OnIsRunningChanged" Margin="2,0,0,0" TextContent="{Binding IsRunning, Converter={StaticResource isRunningToTextConverter}}" FontWeight="Bold" FontSize="8" Color="#FF565656" />
                    <local:EllipseIcon TextContent="TFS" Color="#FF565656" Visibility="{Binding IsTfsSynced, Converter={StaticResource booleanToVisibilityConverter}}"/>
                    <local:EllipseIcon TextContent="Bug" Color="#FF565656" Visibility="{Binding IsBug, Converter={StaticResource booleanToVisibilityConverter}}"/>
                    <local:EllipseIcon TextContent="Due" Color="Red" ToolTip="{Binding DueDateString}" Visibility="{Binding IsExpired, Converter={StaticResource booleanToVisibilityConverter}}"/>
                    <local:EllipseIcon TextContent="Due" Color="Orange" ToolTip="{Binding DueDateString}" Visibility="{Binding WillExpired, Converter={StaticResource booleanToVisibilityConverter}}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
        <VisualBrush x:Key="SearchHint" TileMode="None" Stretch="None" AlignmentX="Left">
            <VisualBrush.Transform>
                <TranslateTransform X="5" Y="0" />
            </VisualBrush.Transform>
            <VisualBrush.Visual>
                <Grid>
                    <TextBlock FontStyle="Italic" Foreground="Black" Opacity="0.3" Text="Type text and press Enter to add an item"/>
                </Grid>
            </VisualBrush.Visual>
        </VisualBrush>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="260"/>
        </Grid.ColumnDefinitions>

        <Grid Grid.ColumnSpan="2" Margin="30">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="26"/>
            </Grid.RowDefinitions>
            <TabControl x:Name="ScenarioTabControl" ItemsSource="{Binding Scenarios}" Background="Gray" VerticalAlignment="Stretch">
                <TabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Title}">
                            <TextBlock.ToolTip>
                                <TextBlock Text="{Binding ShortInfo}"/>
                            </TextBlock.ToolTip>
                        </TextBlock>
                    </DataTemplate>
                </TabControl.ItemTemplate>
                <TabControl.ContentTemplate>
                    <DataTemplate>
                        <ListView ItemsSource="{Binding Tasks}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"/>
                    </DataTemplate>
                </TabControl.ContentTemplate>
            </TabControl>
            <TextBox TextWrapping="Wrap" Grid.Row="1" KeyUp="TextBox_KeyUp" x:Name="inputBar">
                <TextBox.Style>
                    <Style TargetType="TextBox">
                        <Style.Triggers>
                            <Trigger Property="Text" Value="">
                                <Setter Property="Background" Value="{StaticResource SearchHint}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TextBox.Style>
            </TextBox>
        </Grid>

        <local:TimeAccountUC x:Name="timeAccountUc" VerticalAlignment="Bottom"/>
        <local:TracerUC FlowDirection="RightToLeft" Grid.Column="1" VerticalAlignment="Bottom"/>
    </Grid>
</Window>